package com.yaorange.nongjt.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.annotation.Log;
import com.yaorange.common.core.controller.BaseController;
import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.enums.BusinessType;
import com.yaorange.nongjt.domain.NjtUserPerfect;
import com.yaorange.nongjt.service.INjtUserPerfectService;
import com.yaorange.common.utils.poi.ExcelUtil;
import com.yaorange.common.core.page.TableDataInfo;

/**
 * 用户完善信息Controller
 * 
 * @author juheng
 * @date 2025-02-26
 */
@RestController
@RequestMapping("/nongjt/perfect")
public class NjtUserPerfectController extends BaseController
{
    @Autowired
    private INjtUserPerfectService njtUserPerfectService;

    /**
     * 查询用户完善信息列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtUserPerfect njtUserPerfect)
    {
        startPage();
        List<NjtUserPerfect> list = njtUserPerfectService.selectNjtUserPerfectList(njtUserPerfect);
        return getDataTable(list);
    }

    /**
     * 导出用户完善信息列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:export')")
    @Log(title = "用户完善信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtUserPerfect njtUserPerfect)
    {
        List<NjtUserPerfect> list = njtUserPerfectService.selectNjtUserPerfectList(njtUserPerfect);
        ExcelUtil<NjtUserPerfect> util = new ExcelUtil<NjtUserPerfect>(NjtUserPerfect.class);
        util.exportExcel(response, list, "用户完善信息数据");
    }

    /**
     * 获取用户完善信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtUserPerfectService.selectNjtUserPerfectById(id));
    }

    /**
     * 新增用户完善信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:add')")
    @Log(title = "用户完善信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtUserPerfect njtUserPerfect)
    {
        return toAjax(njtUserPerfectService.insertNjtUserPerfect(njtUserPerfect));
    }

    /**
     * 修改用户完善信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:edit')")
    @Log(title = "用户完善信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtUserPerfect njtUserPerfect)
    {
        return toAjax(njtUserPerfectService.updateNjtUserPerfect(njtUserPerfect));
    }

    /**
     * 删除用户完善信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:perfect:remove')")
    @Log(title = "用户完善信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtUserPerfectService.deleteNjtUserPerfectByIds(ids));
    }
}
